gtk/textview: Clean up further if the drag gesture is taken over
authorCarlos Garnacho <carlosg@gnome.org>
Thu, 5 Nov 2020 20:05:18 +0000 (21:05 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 5 Nov 2020 20:29:20 +0000 (21:29 +0100)
If the gesture becomes captured (e.g. from a parent scrolledwindow), we
leave some things in the air. Clean these up properly. This is recurrent
with touch scroll.

gtk/gtktextview.c

index f94067eda1aeea465bffcbc6b775be2ef3359f61..bf3a2b30e369d62aca6cc006237bc13ca4eaa0f8 100644 (file)
@@ -7344,11 +7344,6 @@ gtk_text_view_drag_gesture_end (GtkGestureDrag *gesture,
   priv = text_view->priv;
   sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
 
-  if (!drag_gesture_get_text_surface_coords (gesture, text_view,
-                                             &start_x, &start_y, &x, &y))
-    return;
-
-
   clicked_in_selection =
     g_object_get_qdata (G_OBJECT (gesture), quark_text_selection_data) == NULL;
   g_object_set_qdata (G_OBJECT (gesture), quark_text_selection_data, NULL);
@@ -7363,6 +7358,10 @@ gtk_text_view_drag_gesture_end (GtkGestureDrag *gesture,
   if (priv->magnifier_popover)
     gtk_widget_hide (priv->magnifier_popover);
 
+  if (!drag_gesture_get_text_surface_coords (gesture, text_view,
+                                             &start_x, &start_y, &x, &y))
+    return;
+
   /* Check whether the drag was cancelled rather than finished */
   if (!gtk_gesture_handles_sequence (GTK_GESTURE (gesture), sequence))
     return;